package com.szosen.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import de.greenrobot.dao.AbstractDaoMaster;
import de.greenrobot.dao.identityscope.IdentityScopeType;

import com.szosen.database.HealthRecordDao;
import com.szosen.database.jwsjbDao;
import com.szosen.database.jwsssDao;
import com.szosen.database.jwssxDao;
import com.szosen.database.jwswsDao;
import com.szosen.database.base_infoDao;
import com.szosen.database.ExaminationDao;
import com.szosen.database.NonimmuneInoculationDao;
import com.szosen.database.AccessoryExaminationDao;
import com.szosen.database.HealthAssessmentDao;
import com.szosen.database.LifestySituationDao;
import com.szosen.database.MedicineSituationDao;
import com.szosen.database.InhospitalSituationDao;
import com.szosen.database.OldPeopleSelfCareDao;
import com.szosen.database.ChineseMedicineManageDao;
import com.szosen.database.Visit_infoDao;
import com.szosen.database.Visit_info2Dao;
import com.szosen.database.xueyaDao;
import com.szosen.database.xueyangDao;
import com.szosen.database.tiwenDao;
import com.szosen.database.xuetangDao;
import com.szosen.database.niaoyeDao;
import com.szosen.database.xindianDao;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
 * Master of DAO (schema version 1): knows all DAOs.
 */
public class DaoMaster extends AbstractDaoMaster {
	public static final int SCHEMA_VERSION = 4;

	/** Creates underlying database table using DAOs. */
	public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) {
		HealthRecordDao.createTable(db, ifNotExists);
		jwsjbDao.createTable(db, ifNotExists);
		jwsssDao.createTable(db, ifNotExists);
		jwssxDao.createTable(db, ifNotExists);
		jwswsDao.createTable(db, ifNotExists);
		base_infoDao.createTable(db, ifNotExists);
		ExaminationDao.createTable(db, ifNotExists);
		NonimmuneInoculationDao.createTable(db, ifNotExists);
		AccessoryExaminationDao.createTable(db, ifNotExists);
		HealthAssessmentDao.createTable(db, ifNotExists);
		LifestySituationDao.createTable(db, ifNotExists);
		MedicineSituationDao.createTable(db, ifNotExists);
		InhospitalSituationDao.createTable(db, ifNotExists);
		OldPeopleSelfCareDao.createTable(db, ifNotExists);
		ChineseMedicineManageDao.createTable(db, ifNotExists);
		Visit_infoDao.createTable(db, ifNotExists);
		Visit_info2Dao.createTable(db, ifNotExists);
		xueyaDao.createTable(db, ifNotExists);
		xueyangDao.createTable(db, ifNotExists);
		tiwenDao.createTable(db, ifNotExists);
		xuetangDao.createTable(db, ifNotExists);
		niaoyeDao.createTable(db, ifNotExists);
		xindianDao.createTable(db, ifNotExists);
		UploadRecordDao.createTable(db, ifNotExists);
		xuezhiDao.createTable(db, ifNotExists);
		VisitPlanDao.createTable(db, ifNotExists);
	}

	/** Drops underlying database table using DAOs. */
	public static void dropAllTables(SQLiteDatabase db, boolean ifExists) {
		HealthRecordDao.dropTable(db, ifExists);
		jwsjbDao.dropTable(db, ifExists);
		jwsssDao.dropTable(db, ifExists);
		jwssxDao.dropTable(db, ifExists);
		jwswsDao.dropTable(db, ifExists);
		base_infoDao.dropTable(db, ifExists);
		ExaminationDao.dropTable(db, ifExists);
		NonimmuneInoculationDao.dropTable(db, ifExists);
		AccessoryExaminationDao.dropTable(db, ifExists);
		HealthAssessmentDao.dropTable(db, ifExists);
		LifestySituationDao.dropTable(db, ifExists);
		MedicineSituationDao.dropTable(db, ifExists);
		InhospitalSituationDao.dropTable(db, ifExists);
		OldPeopleSelfCareDao.dropTable(db, ifExists);
		ChineseMedicineManageDao.dropTable(db, ifExists);
		Visit_infoDao.dropTable(db, ifExists);
		Visit_info2Dao.dropTable(db, ifExists);
		xueyaDao.dropTable(db, ifExists);
		xueyangDao.dropTable(db, ifExists);
		tiwenDao.dropTable(db, ifExists);
		xuetangDao.dropTable(db, ifExists);
		niaoyeDao.dropTable(db, ifExists);
		xindianDao.dropTable(db, ifExists);
		UploadRecordDao.dropTable(db, ifExists);
		xuezhiDao.dropTable(db, ifExists);
		VisitPlanDao.dropTable(db, ifExists);
	}

	public static abstract class OpenHelper extends SQLiteOpenHelper {

		public OpenHelper(Context context, String name, CursorFactory factory) {
			super(context, name, factory, SCHEMA_VERSION);
		}

		@Override
		public void onCreate(SQLiteDatabase db) {
			Log.i("greenDAO", "Creating tables for schema version "
					+ SCHEMA_VERSION);
			createAllTables(db, false);
		}
	}

	/** WARNING: Drops all table on Upgrade! Use only during development. */
	public static class DevOpenHelper extends OpenHelper {
		public DevOpenHelper(Context context, String name, CursorFactory factory) {
			super(context, name, factory);
		}

		@Override
		public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
			Log.i("greenDAO", "Upgrading schema from version " + oldVersion
					+ " to " + newVersion + " by dropping all tables");
			// dropAllTables(db, true);
			// onCreate(db);
			db.execSQL("ALTER TABLE XUETANG ADD BEFOREAFTER TEXT");
			db.execSQL("ALTER TABLE XUEYA ADD HAND TEXT");
		}
	}

	public DaoMaster(SQLiteDatabase db) {
		super(db, SCHEMA_VERSION);
		registerDaoClass(HealthRecordDao.class);
		registerDaoClass(jwsjbDao.class);
		registerDaoClass(jwsssDao.class);
		registerDaoClass(jwssxDao.class);
		registerDaoClass(jwswsDao.class);
		registerDaoClass(base_infoDao.class);
		registerDaoClass(ExaminationDao.class);
		registerDaoClass(NonimmuneInoculationDao.class);
		registerDaoClass(AccessoryExaminationDao.class);
		registerDaoClass(HealthAssessmentDao.class);
		registerDaoClass(LifestySituationDao.class);
		registerDaoClass(MedicineSituationDao.class);
		registerDaoClass(InhospitalSituationDao.class);
		registerDaoClass(OldPeopleSelfCareDao.class);
		registerDaoClass(ChineseMedicineManageDao.class);
		registerDaoClass(Visit_infoDao.class);
		registerDaoClass(Visit_info2Dao.class);
		registerDaoClass(xueyaDao.class);
		registerDaoClass(xueyangDao.class);
		registerDaoClass(tiwenDao.class);
		registerDaoClass(xuetangDao.class);
		registerDaoClass(niaoyeDao.class);
		registerDaoClass(xindianDao.class);
		registerDaoClass(UploadRecordDao.class);
		registerDaoClass(xuezhiDao.class);
		registerDaoClass(VisitPlanDao.class);
	}

	public DaoSession newSession() {
		return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
	}

	public DaoSession newSession(IdentityScopeType type) {
		return new DaoSession(db, type, daoConfigMap);
	}

}
